Skip to content

refactor: split monster functions into focused methods#3073

Merged
messense merged 1 commit into
PyO3:mainfrom
messense:split
Mar 9, 2026
Merged

refactor: split monster functions into focused methods#3073
messense merged 1 commit into
PyO3:mainfrom
messense:split

Conversation

@messense

@messense messense commented Mar 9, 2026

Copy link
Copy Markdown
Member

Split the two largest functions in the codebase:

metadata.rs - merge_pyproject_toml (~260 lines -> 8 methods):

  • clear_non_dynamic_fields, merge_version, merge_readme, merge_license, merge_people, merge_optional_dependencies, merge_entry_points, normalize_license_paths

builder.rs - BuildContextBuilder::build (~200 lines -> 4 methods):

  • resolve_interpreters, resolve_build_flags, resolve_sbom_config

@messense messense requested a review from Copilot March 9, 2026 11:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors two large functions by extracting focused helper methods to improve readability and separation of concerns.

Changes:

  • Split merge_pyproject_toml into multiple targeted merge/normalize methods in metadata.rs.
  • Split BuildContextBuilder::build into helper resolvers for interpreters, build flags, and SBOM config in builder.rs.
  • Minor flow reordering around platform tag and PyPI validation handling.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/metadata.rs Extracts merging logic (version/readme/license/people/deps/entrypoints) into dedicated methods and adds license path normalization helper.
src/build_context/builder.rs Extracts interpreter/build-flag/SBOM resolution into helper methods and adjusts where PyPI validation is computed.

Comment thread src/build_context/builder.rs Outdated
Comment thread src/metadata.rs
Split the two largest functions in the codebase:

metadata.rs - merge_pyproject_toml (~260 lines -> 8 methods):
  - clear_non_dynamic_fields, merge_version, merge_readme,
    merge_license, merge_people, merge_optional_dependencies,
    merge_entry_points, normalize_license_paths

builder.rs - BuildContextBuilder::build (~200 lines -> 4 methods):
  - resolve_interpreters, resolve_build_flags, resolve_sbom_config

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@messense messense merged commit 0e90217 into PyO3:main Mar 9, 2026
46 of 48 checks passed
@messense messense deleted the split branch March 9, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants